<?php
/**
 * @author 
 * @copyright 2013
 */
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Smsemail_model extends CI_Model
{
	function __construct(){
		parent::__construct('');            
	}
	
	function Sendsms($sdt,$tinnhan)
    {
        
        if(is_array($sdt)){
		
            $datals['sodienthoai']=$sdt;
            $datals['noidung']=$tinnhan;
            $datals['ngaytao']= gmdate("Y-m-d H:i:s ",time()+7*3600);
            $datals['nguoitao']= $this->admin->login['id'];
            $this->model->table('lichsutinnhan')->insert($datals);
        }
       
      //  $tinnhan = $key.$tinnhan;
        $tinnhan = str_replace(' ', '%20', $tinnhan);
    //$tinnhan = str_replace("/", "%2F", $tinnhan);
        $link = $this->admin->config['smsserver'].'?to='.$sdt."&messenger=".$tinnhan;
    
    //    echo $link;
    //    exit();
    
        $ch = curl_init();


    
        // set URL and other appropriate options set cac thuoc tinh cho no
        curl_setopt($ch, CURLOPT_URL, $link);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FILETIME, true);
    
        // grab URL  thuc thi
        $output = curl_exec($ch);
    
        $intReturnCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);  //lay thong tin ve http_code
    }
      
	function Sendmail($email,$noidung,$subject)
    {
      
        $noidungklgbs = urlencode($noidung); //echo($noidungklgbs); exit();
        
        
        //$noidungklgbx = $key.'_'.($noidungklgbs);
        
        //echo ($noidungklgbx); exit();
        
        $link = 'http://115.78.128.158/testmail.php'.'?to='.$email."&message=".$noidung."&subject=".$subject;
        
        //echo($link); exit();
    
        $ch = curl_init();
        
        //print_r($ch); exit();
        
        // set URL and other appropriate options set cac thuoc tinh cho no
        curl_setopt($ch, CURLOPT_URL, $link);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_FILETIME, true);
    
        // grab URL  thuc thi
        $output = curl_exec($ch);
		//print_r($output ); exit();
    
    
        $intReturnCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);  //lay thong tin ve http_code
    }
 }